#ifndef BSTREE_H
#define BSTREE_H
#include <functional>
#include "BTree.h"

typedef unsigned long long u64;

template<typename T>
class BSTree : public BTree<T> {
    public :
        BSTree() : BTree<T>() {}
	BSTree (T e, u64 k = 0, BSTree *l = NULL, BSTree *r = NULL)
            : BTree<T>(e,l,r), _key(k) {}
        virtual ~BSTree() {}
    protected:
        void rotate_left() {
            BSTree *pivot = this->right;
            this->right = pivot->Left();
            pivot->left = this;
            *this = *pivot;
        }
        void rotate_right() {
            BSTree *pivot = this->left;
            this->left = pivot->Right();
            pivot->right = this;
            *this = *pivot;
        }
        
        u64 _key;
        using BTree<T>::left;
        using BTree<T>::right;
        using BTree<T>::p;
};


#endif /* BSTREE_H */
